﻿using System.Configuration;

namespace ActivateYourGlutes.Data
{
    public class EntityModelFactory : IEntityModelFactory
    {
        public IRepository<T> GetRepository<T>() where T : class
        {
            return
                new EntityFrameworkRepository<T>(
                    ConfigurationManager.ConnectionStrings["ActivateYourGlutesEntities"].ConnectionString);
        }

        public IRepository<T> GetRepository<T>(IRepositoryBase existingRepository) where T : class
        {
            var existingEfRepository = (EntityFrameworkRepositoryBase)existingRepository;
            return new EntityFrameworkRepository<T>(existingEfRepository);
        }
    }
}